/*
 * Copyright (c) http://www.prowidesoftware.com/, 2008. All rights reserved.
 */
package org.rcs.adslmonitor.telnet;

import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;

/**
 *
 * @author mgriffa@prowidesoftware.com
 */
public class TelnetURLStreamHandler extends URLStreamHandler {

  @Override
  protected int getDefaultPort() {
    return 23;
  }

  @Override
  protected void setURL(URL u, String protocol, String host, int port, String authority, String userInfo, String path, String query, String ref) {
    if (-1 == port) {
      port = getDefaultPort();
    }
    super.setURL(u, protocol, host, port, authority, userInfo, path, query, ref);
  }

  @Override
  protected URLConnection openConnection(URL u) throws IOException {
    return new TelnetURLConnection(u);
  }

}
